package com.becca.cake.model.coupon;

import java.io.Serializable;
import java.util.Date;

import org.springframework.format.annotation.DateTimeFormat;

import com.becca.cake.core.exception.ServiceException;
import com.becca.cake.util.StringUtil;

/**
 * 商品活动表
 * @copyright  尊星(上海)信息科技有限公司
 * @author hejinguo
 * @date 2016年6月30日 下午7:09:21
 */
public class GoodsActivityModel implements Serializable {

    /**  */
    private static final long serialVersionUID = 4981454084199759226L;

    private Integer           id;

    private Integer           ruleGroupId;
    /**活动名称*/
    private String            activityName;
    /**活动开始时间*/
    @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
    private Date              activityBeginDate;
    /**活动结束时间*/
    @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
    private Date              activityEndDate;
    /**是否参与其它活动(0:不参与 1:参与)*/
    private Byte              enjoyOtherActivtity;

    /**是否可用(0:可用 1:不可用)*/
    private Byte              isEnable;
    /**创建时间*/
    private Date              createdDate;
    /**创建人*/
    private String            createdName;
    /**修改时间*/
    private Date              updatedDate;
    /**修改人*/
    private String            updatedName;
    /**规则组名称*/
    private String            ruleGroupName;
    
    /**是否可用 0：可用*/
    public static final Byte GOODS_ACTIVITY_IS_ENABLE = 0;
    
    /**商品活动不能为空*/
    public static final String GOODS_ACTIVITY_NULL = "商品活动不能为空";
    /**商品活动名称不能为空*/
    public static final String GOODS_ACTIVITY_NAME_NULL = "商品活动名称不能为空";
    /**规则组不能为空*/
    public static final String RULE_GROUP_NULL = "规则组不能为空";
    /**活动开始时间不能为空*/
    public static final String ACTIVITY_BEGIN_DATE_NULL = "活动开始时间不能为空";
    /**活动结束时间不能为空*/
    public static final String ACTIVITY_END_DATE_NULL = "活动结束时间不能为空";
    /**是否参与其他活动不能为空*/
    public static final String ENJOIN_OTHER_ACTIVITY_NULL = "是否参与其他活动不能为空";
    /**是否可用不能为空*/
    public static final String IS_ENABLE_NULL = "是否可用不能为空";
    /**商品活动ID为空*/
    public static final String ACTIVITY_ID_NULL = "商品活动ID为空";
    
    public static void validAddOrUpdGoodsActivity(GoodsActivityModel goodsActivityModel){
        if(goodsActivityModel == null){
            throw new ServiceException(GoodsActivityModel.GOODS_ACTIVITY_NULL);
        }
        if(StringUtil.isEmpty(goodsActivityModel.getActivityName())){
            throw new ServiceException(GoodsActivityModel.GOODS_ACTIVITY_NAME_NULL);
        }
        if(goodsActivityModel.getRuleGroupId() == null){
            throw new ServiceException(GoodsActivityModel.RULE_GROUP_NULL);
        }
        if(goodsActivityModel.getActivityBeginDate() == null){
            throw new ServiceException(GoodsActivityModel.ACTIVITY_BEGIN_DATE_NULL);
        }
        if(goodsActivityModel.getActivityEndDate() == null){
            throw new ServiceException(GoodsActivityModel.ACTIVITY_END_DATE_NULL);
        }
        if(goodsActivityModel.getEnjoyOtherActivtity() == null){
            throw new ServiceException(GoodsActivityModel.ENJOIN_OTHER_ACTIVITY_NULL);
        }
        if(goodsActivityModel.getIsEnable() == null){
            throw new ServiceException(GoodsActivityModel.IS_ENABLE_NULL);
        }
    }
    
    /**
     * 校验商品活动信息ID是否为空
     * @param id
     */
    public static void  validGoodsActivityIdIsNull(Integer id){
        if(id == null){
            throw new ServiceException(GoodsActivityModel.ACTIVITY_ID_NULL);
        }
    }

    public Integer getId() {
        return id;
    }

    public void setId(Integer id) {
        this.id = id;
    }

    public Integer getRuleGroupId() {
        return ruleGroupId;
    }

    public void setRuleGroupId(Integer ruleGroupId) {
        this.ruleGroupId = ruleGroupId;
    }

    public String getActivityName() {
        return activityName;
    }

    public void setActivityName(String activityName) {
        this.activityName = activityName;
    }

    public Date getActivityBeginDate() {
        return activityBeginDate;
    }

    public void setActivityBeginDate(Date activityBeginDate) {
        this.activityBeginDate = activityBeginDate;
    }

    public Date getActivityEndDate() {
        return activityEndDate;
    }

    public void setActivityEndDate(Date activityEndDate) {
        this.activityEndDate = activityEndDate;
    }

    public Byte getEnjoyOtherActivtity() {
        return enjoyOtherActivtity;
    }

    public void setEnjoyOtherActivtity(Byte enjoyOtherActivtity) {
        this.enjoyOtherActivtity = enjoyOtherActivtity;
    }

    public Byte getIsEnable() {
        return isEnable;
    }

    public void setIsEnable(Byte isEnable) {
        this.isEnable = isEnable;
    }

    public Date getCreatedDate() {
        return createdDate;
    }

    public void setCreatedDate(Date createdDate) {
        this.createdDate = createdDate;
    }

    public String getCreatedName() {
        return createdName;
    }

    public void setCreatedName(String createdName) {
        this.createdName = createdName;
    }

    public Date getUpdatedDate() {
        return updatedDate;
    }

    public void setUpdatedDate(Date updatedDate) {
        this.updatedDate = updatedDate;
    }

    public String getUpdatedName() {
        return updatedName;
    }

    public void setUpdatedName(String updatedName) {
        this.updatedName = updatedName;
    }

    public String getRuleGroupName() {
        return ruleGroupName;
    }

    public void setRuleGroupName(String ruleGroupName) {
        this.ruleGroupName = ruleGroupName;
    }

}
